import {request} from "./request";
import http from  './http'

// 管理员登录
function adminLogin(name, password) {
  return request('http://127.0.0.1:3007/api/loginMag', 'post',{name,password},1)
}
//忘记密码
function forgetpassword(name, phonenumber, newPwd) {
  return request('http://127.0.0.1:3007/api/forgetPasswordMag', 'post',{name,phonenumber,newPwd},1)
}
//获取菜品分类
function getfoodclass() {
  return request('http://127.0.0.1:3007/api/article/cates', 'get','',1)
}
//添加分类
function addfoodclass(name) {
  return request('http://127.0.0.1:3007/api/article/addcates','post', {name},1)
}
//删除菜品分类
function deletefoodclass(id,is_delete) {
  return request(`http://127.0.0.1:3007/api/article/deletecate/${id}/${is_delete}`,'get','',1)
}
//修改菜品分类
function changefoodclass(Id,name) {
  return request('http://127.0.0.1:3007/api/article/updatecate', 'post', {Id,name}, 1)
}
// 获取所有菜品
function getfood(pageNum, pageSize){
  return request('http://127.0.0.1:3007/api/article/allDetails','post',{pageNum, pageSize}, 1)
}
//添加菜品
function addfood(name, classification_id, price, picture, inventory) {
  return request('http://127.0.0.1:3007/api/article/add', 'post', {name, classification_id, price, picture, inventory}, 1)
}
//修改菜品name
function changefood(food_id, name, classification_id, price, picture, inventory) {
  return request('http://127.0.0.1:3007/api/article/updateFood', 'post', {food_id, name, classification_id, price, picture, inventory}, 1)
}
//修改菜品
function changefood1(food_id, classification_id, price, picture, inventory) {
  return request('http://127.0.0.1:3007/api/article/updateFood', 'post', {food_id, classification_id, price, picture, inventory}, 1)
}
//修改菜品推荐
function recommendedfood(food_id, recommended) {
  return request('http://127.0.0.1:3007/api/article/dealRecommend', 'post', {food_id, recommended}, 1)
}
//删除、恢复菜品
function deletefood(food_id, is_delete) {
  return request(`http://127.0.0.1:3007/api/article/deleteUserdetails/${food_id}/${is_delete}`, 'get', '', 1)
}
//查询订单
function getinfo(dining, pageSize, pageNum) {
  return request('http://127.0.0.1:3007/api/info/diningInfo', 'post', {dining, pageSize, pageNum}, 1)
}
//查询座位
function getseat() {
  return request('http://127.0.0.1:3007/api/info/tableInforAll', 'get', '', 1)
}
//添加座位
function addseat(table_id) {
  return request('http://127.0.0.1:3007/api/info/tableAdd', 'post', {table_id}, 1)
}
//修改座位使用情况
function changeseat(table_id, is_use) {
  return request('http://127.0.0.1:3007/api/info/tableUse', 'post', {table_id, is_use}, 1)
}
//删除座位
function deleteseat(table_id) {
  return request('http://127.0.0.1:3007/api/info/tableDelete', 'post', {table_id}, 1)
}
//查询留言
function getmessage() {
  return request('http://127.0.0.1:3007/api/info/feedbackView', 'get', '', 1)
}
// 获取菜品销售情况
function getfoode(pageNum, type){
  return request('http://127.0.0.1:3007/api/article/allDetails','post',{pageNum, pageSize:10, type}, 1)
}
function change



//上传图片
function pictureL(file) {
  let pictureL = new FormData();
  pictureL.append('file',file)
  pictureL.append('fileUseForEnum','BBS')
  return http.post('/course-api/api/nos/upload/image',pictureL)
}


export {
  adminLogin,
  forgetpassword,
  getfoodclass,
  addfoodclass,
  deletefoodclass,
  changefoodclass,
  getfood,
  addfood,
  changefood,
  changefood1,
  recommendedfood,
  deletefood,
  getinfo,
  getseat,
  addseat,
  changeseat,
  deleteseat,
  getmessage,
  getfoode,
  pictureL
}
